import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;

public class Sanpang {
        public static void main(String[] args) {
//            Arrays[]list=new Arrays[3];
            File a = new File("C:\\Users\\my\\Desktop\\JAVA\\JAVA作业\\test.txt");
            File file = new File("C:\\Users\\my\\Desktop\\JAVA\\JAVA作业\\test1.txt");
            FileInputStream in = null;
            FileOutputStream out = null;
            try {
                in = new FileInputStream("C:\\Users\\my\\Desktop\\JAVA\\JAVA作业\\test.txt");
//            File file = new File("C:\\Users\\my\\Desktop\\JAVA\\JAVA作业\\test1.txt");
                if (!file.exists()) {
                    file.getParentFile().mkdirs();
                    file.createNewFile();
                }
                out = new FileOutputStream(file);
                int b = 0;
                while ((b = in.read()) != -1) {
                    out.write(b);
                }
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                try {
                    if (in != null) {
                        in.close();
                    }
                    if (out != null) {
                        out.close();
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
                System.out.println("已将"+a+"写入并覆盖"+file);
            }
        }
    }
